package cn.bugstack.domain.order.service;

import cn.bugstack.domain.order.model.entity.OrderEntity;
import cn.bugstack.domain.order.model.entity.PayOrderEntity;
import cn.bugstack.domain.order.model.entity.ShopCartEntity;
import com.alipay.api.AlipayApiException;

import java.util.Date;
import java.util.List;

public interface IOrderService {

    // 创建新订单
    PayOrderEntity createOrder(ShopCartEntity shopCartEntity) throws Exception;

    // 更改订单为支付状态
    void changeOrderPaySuccess(String orderId, Date orderTime);

    // 查询处于等待支付状态 且 下单超过一分钟的订单
    List<String> queryNoPayNotifyOrder();

    // 查询超时订单, 处于等待支付状态 且 下单超过30分钟的的订单
    List<String> queryTimeoutCloseOrderList();

    // 修改订单为关单状态
    boolean changeOrderClose(String orderId);

    // 批量结算订单，更新数据库状态,发送结算消息至监听器，触发后续操作
    void changeOrderMarketSettlement(List<String> outTradeNoList);

    // 查询用户Id 的支付订单
    List<OrderEntity> queryUserOrderList(String userId, Long lastId, Integer pageSize);

    // 营销退单
    boolean refundMarketOrder(String userId, String orderId);

    // 接收拼团退单消息，去支付宝退款并更新支付订单状态
    boolean refundPayOrder(String userId, String orderId) throws AlipayApiException;

    // 判断订单是否为普通订单
    boolean checkMarket(String orderId);

    // 非营销订单退单
    boolean refundNoMarketOrder(String userId, String orderId);
}
